function Tab(el,option = {}){//el为了方便操作不同模块的tab
    this.el = document.querySelector(el)
    this.option = option
    this.init()
}
//开关
Tab.prototype.init=function(){
    this.changeLi()
    this.optionData()
}
//同步内容函数
Tab.prototype.same=function(i){//传i值方便判断
    this.el.querySelector('ol li.active').className=''
    this.el.querySelector(`ol li:nth-of-type(${i+1})`).className='active'
}
//获取option内的数据 
Tab.prototype.optionData=function(){
    this.option.active= this.option.active||'white'//设置默认颜色
}
//鼠标移入Li active改变函数
Tab.prototype.changeLi=function(){
    //获取所有Li
    var liObjs = this.el.querySelectorAll('ul li')
    liObjs.forEach((item,i)=>{
        item.onmouseover = ()=>{
            this.el.querySelector('ul li.active').className=''
            item.className='active'
            this.same(i)
            //改变字体颜色
            this.el.querySelectorAll('ul li').forEach((item)=>{
                item.style.color='white'
            })
            item.style.color=this.option.active
        }
    })
}
export default Tab;